﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using Model;

namespace Dal
{
    public class DbHouseRegionDal
    {
        public DbHouseRegionDal()
		{
		}

        #region Select
        public static DataSet Select()
        {
            string sql = "select a.* from DbHouseRegion a ";
            return SqlHelper.Select(sql);
        }

        public static DbHouseRegion Select(Int32 houseRegionID)
        {
            DbHouseRegion dbHouseRegion = null;
            string sql = @"select a.* from DbHouseRegion a  where a.houseRegionID= {0} ";
            sql = string.Format(sql, houseRegionID);
            DataSet ds = SqlHelper.Select(sql);
            if (SqlHelper.HasRow(ds))
                dbHouseRegion = new DbHouseRegion(ds.Tables[0].Rows[0]);
            return dbHouseRegion;
        }

        public static DataSet Select(string where)
        {
            if (where.Trim().ToLower().StartsWith("where"))
                where = where.Substring(5);
            if (!where.Trim().ToLower().StartsWith("and") && where.Trim().Length > 0)
                where = " and " + where;
            string sql = "select a.* from DbHouseRegion a  where 1=1 " + where;
            return SqlHelper.Select(sql);
        }

        #endregion
    }
}
